package com.ncloud.crm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.*;

import com.ncloud.crm.entity.BsNodeNetAccess;
@Mapper
public interface BsNodeNetAccessMapper {

	@Insert("insert into bs_net_access(node_id, isp_inst_id, isp_name, net_type,net_name, access_type, isp_width, begin_date, end_date, update_time, update_user,access_ip_addr,access_gateway)"
			+ " values(#{nodeId}, #{ispInstId}, #{ispName},#{netType},#{netName}, #{accessType}, #{ispWidth}, #{beginDate}, #{endDate}, #{updateTime}, #{updateUser},#{accessIpAddr},#{accessGateway})")
	int insertNetAccess(BsNodeNetAccess netAccess);

	@Update("update bs_net_access set isp_name=#{ispName},net_type=#{netType}, access_type=#{accessType},isp_width= #{ispWidth}, end_date= #{endDate},"
			+ " update_time=#{updateTime},update_user=#{updateUser} where isp_inst_id = #{ispInstId} and begin_date = #{beginDate}")
	int updateNetAccess(BsNodeNetAccess netAccess);

	@Select(value = { "select * from bs_net_access where isp_inst_id = #{ispInstId} and now() between begin_date and end_date" })
	@Results({ @Result(column = "node_id", property = "nodeId"), @Result(column = "isp_name", property = "ispName"),
			@Result(column = "access_type", property = "accessType"),@Result(column = "isp_width", property = "ispWidth"),
			@Result(column="begin_date",property="beginDate"),@Result(column="end_date",property="endDate"),
			@Result(column="update_time",property="updateTime"),@Result(column="update_user",property="updateUser"),
			@Result(column="isp_inst_id",property="ispInstId"),@Result(column="net_type",property="netType"),
			@Result(column="net_name",property="netName"),
			@Result(column="access_gateway",property="accessGateway"),@Result(column="access_ip_addr",property="accessIpAddr")
	})
	public BsNodeNetAccess getNodeNetAccessByPk(Long isp_inst_id);

	@Select(value = { "select * from bs_net_access where node_id = #{nodeId} and now() between begin_date and end_date" })
	@Results({ @Result(column = "node_id", property = "nodeId"), @Result(column = "isp_name", property = "ispName"),
			@Result(column = "access_type", property = "accessType"),@Result(column = "isp_width", property = "ispWidth"),
			@Result(column="begin_date",property="beginDate"),@Result(column="end_date",property="endDate"),
			@Result(column="update_time",property="updateTime"),@Result(column="update_user",property="updateUser"),
			@Result(column="isp_inst_id",property="ispInstId"),@Result(column="net_type",property="netType"),
			@Result(column="net_name",property="netName"),
			@Result(column="access_gateway",property="accessGateway"),@Result(column="access_ip_addr",property="accessIpAddr")})
	List<BsNodeNetAccess> getNodeNetAccesses(Long nodeId);

	@Select(value = { "select * from bs_o_work_net_access where node_id = #{nodeId} and now() between begin_date and end_date" })
	@Results({ @Result(column = "work_id", property = "workId"), @Result(column = "modify_tag", property = "modifyTag"),
			@Result(column = "node_id", property = "nodeId"),@Result(column = "net_type", property = "netType"),
			@Result(column="isp_inst_id",property="ispInstId"),@Result(column="isp_name",property="ispName"),
			@Result(column="access_ip_addr",property="accessIpAddr"),@Result(column="access_gateway",property="accessGateway"),
			@Result(column="access_type",property="accessType"),@Result(column="isp_width",property="ispWidth"),
			@Result(column="begin_date",property="beginDate"),@Result(column="end_date",property="endDate"),
			@Result(column="update_time",property="updateTime"),@Result(column="update_user",property="updateUser"),
			@Result(column="net_name",property="netName")})
	List<BsNodeNetAccess> getBsNodeNetAccesses(Long nodeId);
}
